package com.tchhy.mvplibrary.ui.fragment

import android.os.Bundle
import com.tchhy.mvplibrary.presenter.BasePresenter
import com.tchhy.mvplibrary.presenter.view.BaseView
import com.tchhy.mvplibrary.ui.inject.InjectUtils
import com.tchhy.provider.rx.BaseException

/**
 * Author: wfy
 *
 * time: 2018/8/22
 *
 */
abstract class BaseMvpFragment<T : BasePresenter<*>> : BaseFragment(), BaseView {
    lateinit var mPresenter: T


    override fun onActivityCreated(savedInstanceState: Bundle?) {
        InjectUtils.injectFragment(this)
        super.onActivityCreated(savedInstanceState)
    }
    override fun initView() {
    }

    open fun isShowLoading(): Boolean {
        return true
    }

    override fun showLoading() {
        if (isShowLoading() && !mProgressLoadingDialog!!.isShowing) {
            mProgressLoadingDialog?.showLoading()
        }
    }

    override fun dismissLoading() {
        if (mProgressLoadingDialog!!.isShowing) {
            mProgressLoadingDialog?.dismissLoading()
        }
    }

    override fun onError(throwable: BaseException) {
    }

    override fun onError(errorMessage: String) {

    }

}